package cn.iocoder.yudao.module.xhyy.controller.app.exam;

import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;

import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import javax.validation.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;


import cn.iocoder.yudao.module.xhyy.controller.app.exam.vo.*;
import cn.iocoder.yudao.module.xhyy.dal.dataobject.exam.ExamDO;
import cn.iocoder.yudao.module.xhyy.service.exam.ExamService;

@Tag(name = "用户 APP - 试卷资源")
@RestController
@RequestMapping("/xhyy/exam")
@Validated
public class AppExamController {

    @Resource
    private ExamService examService;


    @GetMapping("/get")
    @Operation(summary = "获得试卷资源")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<AppExamRespVO> getExam(@RequestParam("id") String id) {
        ExamDO exam = examService.getExam(id);
        return success(BeanUtils.toBean(exam, AppExamRespVO.class));
    }

    @GetMapping("/page")
    @Operation(summary = "获得试卷资源分页")
    public CommonResult<PageResult<AppExamRespVO>> getExamPage(@Valid AppExamPageReqVO pageReqVO) {
        PageResult<ExamDO> pageResult = examService.getExamPage(pageReqVO);
        return success(BeanUtils.toBean(pageResult, AppExamRespVO.class));
    }



}